// src/stores/userinfo.js
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('userinfo', () => {
  const userInfo = ref(null)

  const setUserInfo = (user) => {
    userInfo.value = user
  }
  // 清空用户信息
  const clearUserInfo = () => {
    userInfo.value = null
  }

  return {
    userInfo,
    setUserInfo,
    clearUserInfo
  }
}, {
  persist: {
    key: 'user-info',
    storage: localStorage,
    paths: ['userInfo']
  }
})